home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1996 #6
/
Amiga Plus CD - 1996 - No. 06.iso
/
pd
/
texte
/
wordwrap
/
wordwrap.doc
< prev
next >
Wrap
Text File
|
1996-08-09
|
4KB
|
103 lines
WordWrap
========
"wordwrap" is a text filter that rearranges the line breaks in a plain
ASCII text, preserving paragraphs (or ignoring them, if you wish :)=).
I wrote it, because I often encounter strangely formatted but large texts
on usenet -- and because I don't own an editor like TurboText that can
reformat paragraphs. ;-)
Usage
-----
wordwrap [options] <original_file >new_file
options are:
-l<len> output line length, defaults to 75
-b protect blank lines
-i protect indentation
-i<indent> " , enforcing a fixed indentation width
-s<maxlen> protect short input lines
Notes
-----
Try "-l1": this will create ouput with one word per line. Fun! ;-)
The -b option that preserves blank lines is highly recommended in all
cases. You will find very few texts that look good without it.
The -i option assumes that each indented line is the start of a new
paragraph, like in this section. This will also protect the line break
of indented blocks like the options list above or the heading on top of
this document.
Maybe you don't like the way these paragraphs are indented by only
four spaces each (or perhaps you've even got a document with a variable
indentation width): Try -i6, this will indent anything in the text that
isn't left aligned by exactly 6 spaces, even those parts that were indented
by tabs.
When you wordwrap this text you should notice how the dashes
underlining the section headings are wrapped in an unwanted way. Try -s20,
this will insert a line break after each input line containing less than
20 non-blank characters: voilà. B.t.w., it's hard to do any damage with
this option, you might have even said -s40 or -s60. In a text originally
formatted for 75 columns like this, it is unlikely to encounter a line
shorter than 60 characters within a paragraph.
Examples
--------
Most of these examples do not redirect their output, because I think
playing with the options is nicer this way.
wordwrap <wordwrap.doc ; can you read this? :)
wordwrap <wordwrap.doc -b ; much better
wordwrap <wordwrap.doc -b -s20 ; makes "underline" work
wordwrap <wordwrap.doc -b -s20 -i ; for those indented paragraphs
wordwrap <wordwrap.doc -b -s20 -i -l40 ; now try some text widths
wordwrap <wordwrap.doc -b -s20 -i -l60 ; this is nice ...
wordwrap <wordwrap.doc -b -s20 -i -l60 >wwr.doc ; keep it
When you look at the output "wwr.doc" you will notice that it still
needs some editing. This will be true for most real-life applications,
too. Nevertheless, I think "wordwrap" does a damn good job.
Known problems
--------------
The -i and -s options cannot fully prevent that the alignment of tables
or ASCII art diagrams is recklessly destroyed. However, I am not going to
take any further efforts in this matter. You must either restore such
sections manually, or insert a copy from the original document. If this
occurs too frequently, well, tough luck: Don't reformat such a text with
"wordwrap" then.
Lines indented with tab characters are likely to become too long in the
output, because "wordwrap" knows nothing about tabs and counts them just
like simple spaces. In some cases -i4 or -i8 instead of -i may help.
If this is not what you want, you must first convert all tabs to spaces,
using a utility like "detab" (or maybe your text editor).
The notorious combination CR/LF is no problem (the CR's are simply
stripped), however LF/CR (note the reverse order) might confuse "wordwrap"
when using -i. I don't know if this ever occurs, but if it does, you will
have to use a different text filter to strip those CR's first.
Credits
-------
This program was written using EdWord and the GNU C compiler.
"wordwrap" is Freeware/Mailware: If you like it, send me E-Mail:
wnoeker@t-online.de
(Wilhelm Noeker)